<?
	$result = 0;

	ini_set('memory_limit', '48M');

	$files = new Files();

	foreach($_POST['name'] as $k => $v){

		if($file = upload("upload$k")){

			$info['aid'] = $_POST['id'];
			$info['acid'] = $k;
			$info['upload'] = $file[0];

			$path_parts = pathinfo($file[0]);

			$info['name'] = $path_parts['filename'].".".$path_parts['extension'];
			$info['icon'] = $files->get_icon($file[1]);

			$db->insert("assessment_file", $info);
		}

		$stand = array();
		$stand['result'] = trim($v);

		$db->update("assessment_standard", $stand, "id=".$k);
		
		if(trim($v) != ""){
			$result++;
		}
	}

	$assessment = $dsfm_common->get("assessment", "id=".$_POST['id']);

	$data['evaluation'] = $dsfm_common->evaluation($result, $assessment);
	$data['target'] = $_POST['target'];
	$data['indicator'] = $_POST['indicator'];
	$data['collector'] = $_POST['collector'];
	$data['project'] = $_POST['project'];
	$data['result'] = $result;

	$db->update("assessment", $data, "id=".$_POST['id']);

	redirect("assessment.php?id=".$_POST['id']);
?>